﻿using GlennQuigmire.API.Application.Commands;
using GlennQuigmire.API.Application.GDtos;
using IMES.Common.Domain.SirModel;
using IMES.Common.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace GlennQuigmire.API.Controllers
{
    /// <summary>
    /// 出库单控制器--API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutboundOrderController : ControllerBase
    {

        private readonly IMediator mediator;

        public OutboundOrderController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 查询出库单列表
        /// </summary>
        /// <param name="cmd">查询出库单列表请求对象</param>
        /// <returns>查询出库单列表结果对象</returns>
        [HttpPost]
        public Task<ResultT<OutboundOrderListDto>> OutboundOrderList(OutboundOrderSearchCommand cmd)
        {
            return mediator.Send(cmd);
        }

        /// <summary>
        /// 创建出库单
        /// </summary>
        /// <param name="cmd">出库单添加信息</param>
        /// <returns>返回响应对象</returns>
        [HttpPost]
        public Task<Result> OutboundOrderCreate(OutboundOrderCreateCommand cmd)
        {
            return mediator.Send(cmd);
        }

        /// <summary>
        /// 获取出库单类型列表（下拉框数据）
        /// </summary>
        /// <param name="cmd">获取出库单类型列表请求对象</param>
        /// <returns></returns>
        [HttpGet]
        public Task<ResultT<OutboundOrderType>> GetOutboundOrderTypeList([FromQuery]OutboundOrderTypeSearchCommand cmd)
        {
            return mediator.Send(cmd);
        }

        /// <summary>
        /// 根据id查询入库单的产品信息
        /// </summary>
        /// <param name="cmd">根据id查询入库单的产品信息请求对象</param>
        [HttpPost]
        public Task<ResultT<Product>> OutboundOrderProductDetail(OutboundOrderProductDetailCommand cmd)
        {
            return mediator.Send(cmd);
        }


        /// <summary>
        /// 根据选的出库单查询出库单商品
        /// </summary>
        /// <param name="cmd">出库单商品查询请求对象</param>
        /// <returns>返回出库单产品列表</returns>
        [HttpPost]
        public Task<ResultT<OutboundOrderProductsDto>> OutboundOrderProductSearch(OutboundOrderProductSearchCommand cmd)
        {
            return mediator.Send(cmd);
        }



    }
}
